package O3.workflow;

import java.util.Scanner;

public class SwitchCon {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter your favourate fruit:");
        String fruit = scanner.nextLine();
        switch (fruit){
            case "apple":
                System.out.println("Apple");
                break;
            case "pear":
                System.out.println("Pear");
                break;
            default:
                System.out.println("Nothing matched");
        }

//        Below Code Are Not Supported in java8
//        String tt = "apple";
//        int opt = switch (tt) {
//            case "apple" -> 1;
//            case "pear", "mango" -> 2;
//            default -> 0;
//        }; // 注意赋值语句要以;结束
//        System.out.println("opt = " + opt);
//        String tt = "orange";
//        int opt = switch (fruit) {
//            case "apple" -> 1;
//            case "pear", "mango" -> 2;
//            default -> {
//                int code = fruit.hashCode();
////                yield code; // switch语句返回值
//            }
//        };
//        System.out.println("opt = " + opt);

    }
}
